package com.example.practice.service.impl;

import com.example.practice.entity.StudentLocation;
import com.example.practice.dao.StudentLocationDao;
import com.example.practice.service.StudentLocationService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (StudentLocation)表服务实现类
 *
 * @author makejava
 * @since 2024-01-04 10:23:07
 */
@Service("studentLocationService")
public class StudentLocationServiceImpl implements StudentLocationService {
    @Resource
    private StudentLocationDao studentLocationDao;

    /**
     * 通过ID查询单条数据
     *
     * @return 实例对象
     */
    @Override
    public StudentLocation queryById(Integer uid,Integer aid) {
        return this.studentLocationDao.queryById(uid,aid);
    }

    /**
     * 分页查询
     *
     * @param studentLocation 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<StudentLocation> queryByPage(StudentLocation studentLocation, PageRequest pageRequest) {
        long total = this.studentLocationDao.count(studentLocation);
        return new PageImpl<>(this.studentLocationDao.queryAllByLimit(studentLocation, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param studentLocation 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(StudentLocation studentLocation) {
        return this.studentLocationDao.insert(studentLocation);
    }


    @Override
    public Integer deleteById(Integer uid,Integer aid) {
        return this.studentLocationDao.deleteById(uid,aid);
    }
}
